<template>
	<view style="position: relative;overflow: auto;height: 100vh;">
		<!--  height: 182rpx; -->
		<view class="headerCont" style="position: sticky;top:0;z-index: 1; background-color: #fff;">
			<view style="height: 88rpx;">
				<u-navbar :fixed="false" :placeholder="true" left-icon="" class="custom-nav"  :title="current == 0 ? '招标' + '项目订阅' : '工程' + '项目订阅'" :safeAreaInsetTop="true"  rightText="添加" rightIcon="/static/img/custom/add.png"  @rightClick="togglePopup('center', 'image')">
				</u-navbar>
			</view>
			<!-- :fixed="true" :scrollFlag='true' -->
			<view style="height: 94rpx;margin-top:68rpx;">
				<tabControl :fixed="false" :current="current" :values="tabList"  bgc="#fff"
					:isEqually='true' @clickItem="onClickItem"></tabControl>
			</view>
		</view>
		<view class="custom-container">
			<!--订阅信息列表 -->
			<view v-if="current === 0">
				<!-- 没有订阅关键词 -->
				<view class="custom-null-container" v-if="listisnone" :style="{height:swiperHeight - 130 + 'px'}">
					<view class="null-pic">
						<image src="/static/img/custom/null.png"></image>
					</view>
					<view class="null-text">什么都没有，快去订阅关键词~</view>
					<view class="add-gjc">
						<button @click="togglePopup('center', 'image')">添加关键词</button>
					</view>
					<view class="gxdz-tips" v-if="!this.baseConfig.isIOSshenhe" @click="togglePopup('center', 'tip')">
						什么是个性化项目订阅<image src="../../../static/img/custom/wen.png" class="wen-icon"></image>
					</view>
				</view>
				<view class="custom-list" v-else>
					<view class="custom-list-item" v-for="(list, key) in listData" :key="key">
						<view class="fenge"></view>
						<!-- <view class="custom-time">{{list.time}}</view> -->
						<view class="list-item-box">
							<view class="custom-keywords">
								<image src="/static/img/custom/keywords.png" class="keyword-icon"></image>
								<text class="keyword-text" style="flex: 1;">{{list.keyword}}</text>
								<view class="custom-type-right" style="display: flex; align-items: center;"
									@click="zbZhiding(list.id)">
									<image src="@/static/zhiding.png" style="width: 30px;height: 30px;"></image> 置顶
								</view>
							</view>
							<view class="custom-type">
								<view class="custom-type-left">
									<view class="type-text">地区：{{list.area}}</view>
									<view class="type-text custom-leibie">类别： {{list.category}}</view>
									<view class="type-text">范围： {{list.scope}}</view>
								</view>

							</view>
							<view class="custom-editor">
								<view class="custom-dete" @click="dingyueupdate(list.id,3)">
									<image src="/static/img/custom/delete-new.png"></image> 删除
								</view>
								<view class="custom-modify" @click="modify(list)">
									<image src="/static/img/custom/modify-new.png"></image> 修改
								</view>
								<!-- #ifdef APP-PLUS -->
								<view class="custom-switch">
									<switch @change="switch1Change" :checked="list.status==0" :data-index="key"
										style="transform: scale(0.6); margin-right: -5px;" />
									<view class="">{{list.status==1?"开启推送":"关闭推送"}}</view>
								</view>
								<!-- #endif -->
								<view class="custom-results" @click="goDetail(list)">查看结果</view>
							</view>
						</view>
					</view>

					<view class="custom-time-fen" :style="maillistData.length<=0?'display:none':''">以下为PC端邮件定制</view>
					<view class="custom-list-item" style="margin-bottom: 20rpx;" v-for="(list, mailkey) in maillistData"
						:key="'mail'+mailkey">
						<view class="list-item-box">
							<view class="custom-keywords">
								<image src="/static/img/custom/pcmail.png" class="keyword-icon"></image>
								<text class="keyword-text">{{list.keyword}}</text>
								<!-- 	<view class="custom-type-right">
									<text class="custom-number">{{list.count}}</text>
								</view> -->
							</view>
							<view class="custom-type">
								<view class="custom-type-left">
									<view class="type-text">地区：{{list.area}}</view>
									<view class="type-text custom-leibie">类别： {{list.category}}</view>
									<view class="type-text">范围： {{list.scope}}</view>
									<view class="type-text">邮箱： {{list.email}}</view>
								</view>

							</view>
							<view class="custom-editor">
								<view class="custom-dete" @click="mailclick">
									<image src="/static/img/custom/delete-new.png"></image> 删除
								</view>
								<view class="custom-modify" @click="mailclick">
									<image src="/static/img/custom/modify-new.png"></image> 修改
								</view>
								<!-- #ifdef APP-PLUS -->
								
								<view class="custom-switch">
									<view class="youx-switch" @click="mailclick">
										<view class="switch-mask"></view>
										<switch :checked="list.status==0"
											style="transform: scale(0.6); margin-right: -5px;" />
									</view>

									<view class="">{{list.status==1?"开启推送":"关闭推送"}}</view>
								</view>
								<!-- #endif -->
								<view class="custom-results" @click="goDetailmail(list)">查看结果</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-else>
				<!-- 没有订阅关键词 -->
				<view class="custom-null-container" v-if="gclistData.length<=0"
					:style="{height:swiperHeight - 130 + 'px'}">
					<view class="null-pic">
						<image src="/static/img/custom/null.png"></image>
					</view>
					<view class="null-text">什么都没有，快去订阅吧~</view>
					<view class="add-gjc">
						<button style="background-color: #f98d28;" @click="togglePopup('center', 'gc')">添加工程订阅</button>
					</view>
					<view class="gxdz-tips" v-if="!this.baseConfig.isIOSshenhe" @click="togglePopup('center', 'tip')">
						什么是个性化项目订阅<image src="../../../static/img/custom/wen.png" class="wen-icon"></image>
					</view>
				</view>
				<view class="custom-list gongcheng-custom" v-else>
					<view class="custom-list-item" v-for="(list, key) in gclistData" :key="key">
						<view class="fenge"></view>
						<!-- <view class="custom-time">{{list.time}}</view> -->
						<view class="list-item-box">
							<view class="custom-keywords">
								<image src="/static/img/custom/keywords.png" class="keyword-icon"></image>
								<text class="keyword-text" style="flex: 1;">工程信息订阅</text>
								<view class="custom-type-right" style="display: flex;align-items: center;"
									@click="gcZhiding(list.id)">
									<image src="@/static/zhiding.png" style="width: 30px;height: 30px;"></image> 置顶
								</view>
							</view>
							<view class="custom-type">
								<view class="custom-type-left">
									<view class="type-text">地区：{{list.area}}</view>
									<view class="type-text custom-leibie">类型： {{list.typestr}}</view>
									<view class="type-text">阶段： {{list.jieduanstr}}</view>
								</view>

							</view>
							<view class="custom-editor">
								<view class="custom-dete" @click="gcdingyueupdate(list.id,3)">
									<image src="/static/img/custom/delete-new.png"></image> 删除
								</view>
								<view class="custom-modify" @click="gcmodify(list)">
									<image src="/static/img/custom/modify-new.png"></image> 修改
								</view>
								<!-- #ifdef APP-PLUS -->
								
								<view class="custom-switch">
									<switch @change="gcswitchChange" color="#f98d28" :checked="list.status==0"
										:data-index="key" style="transform: scale(0.6); margin-right: -5px;" />
									<view class="">{{list.status==1?"开启推送":"关闭推送"}}</view>
								</view>
								<!-- #endif -->
								<view class="custom-results" @click="gcResultlist(list)">查看结果</view>
							</view>
						</view>

					</view>
				</view>
			</view>
			<!-- 订阅说明 -->
			<uni-popup ref="showtip" :type="type" :mask-click="true">
				<scroll-view scroll-y="true" class="dingzhishuoming">
					<view class="instructionpop">
						<view class="instruction-title">个性化项目订阅说明</view>
						<view class="instruction-text">
							<view class="text-title">什么是个性化项目订阅？</view>
							<view class="text-graph">会员根据自己的需要，设定搜索词和搜索条件，系统根据订阅 条件显示检索结果。</view>
							<view class="text-graph">同时可设定提醒短信、邮件提醒的接收人。</view>
						</view>
						<view class="instruction-text">
							<view class="text-title">价值解析</view>
							<view class="text-graph">1.通过个性化订阅，会员可以在登录后直接查看所需的信息， 使用更方便。</view>
							<view class="text-graph">2.在所需信息更新后，系统通过短信、邮件等方式进行提醒， 保证及时获得项目更新信息</view>
							<view class="text-graph">3.节省会员项目搜索时间。</view>
						</view>
						<view class="instruction-text">
							<view class="text-title">使用方式</view>
							<view class="text-graph">a.在会员中心设定；</view>
							<view class="text-graph">b.在搜索结果页，点击储存为订阅条件；</view>
							<view class="text-graph">查看：会员中心首页，项目订阅结果中查看；</view>
							<view class="text-graph">修改：在会员中心进行修改；</view>
							<view class="text-graph">每个用户都可订阅1条招标信息，1条工程信息， 您可咨询电话：<text @click="yunyingshang"
									style="color: #ff0000;">{{serverTelHost}}</text></view>
						</view>
					</view>
				</scroll-view>
			</uni-popup>

		</view>
		<z-navigation></z-navigation>
		<uni-popup ref="showpowerPop" type="center" :mask-click="true">
			<view class="powerPop">
				<image src="/static/img/Details/huiyuan_close.png" class="power-close"
					@click="$refs['showpowerPop'].close();"></image>
				<view class="power_cont">
					<view style="font-weight: bold; font-size: 32rpx; margin: 10rpx 0 15rpx;">开启消息通知</view>
					<view style="color: #666666; font-size: 28rpx; margin-bottom: 50rpx;">即可实时获取最新项目信息</view>
					<image src="/static/quanxiantongzhi.png" class="quanxiantongzhi-img"></image>
					<view class="lijikaiqi" @click="Setup()">立即开启</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import zNavigation from '@/components/navigation/navigation.vue';
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import uniIcons from '@/components/uni-icons/uni-icons.vue'
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
	import tabControl from '@/components/tabControl-tag/dingyue-tabControl.vue';
	export default {
		components: {
			uniPopup,
			uniLoadMore,
			uniIcons,
			uniNavBar,
			tabControl,
			zNavigation
		},
		data() {

			return {
				type: '',
				items: [{
						src: '/static/img/custom/zhaobiao.png',
						value: '',
						name: '招标订阅'
					},
					{
						src: '/static/img/custom/gongcheng.png',
						value: '',
						name: '工程订阅'
					}
				],
				listisnone: false,
				gclistisnone: false,
				// switchtext: '开启推送',
				current: 0,
				serverTelHost: this.baseConfig.serverTelHost,
				status: 'more',
				last_id: '',
				refreshing: false,
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				},
				listData: [],
				maillistData: [],
				gclistData: [],
				tabList: [{
						title: '招标项目订阅'
					},
					{
						title: '工程信息订阅'
					}
				],
				contHei: 0,
				swiperHeight: 0,
				tuisong: true,
				dyid: 0,
				navtitle: this.current == 0 ? "招标" : "工程"
			}
		},
		onLoad() {

			// //#ifdef APP-PLUS
			// this.isKaiqiTongzhi();
			// if (!this.tuisong) {
			// 	this.$nextTick(() => {
			// 		this.$refs['showpowerPop'].open()
			// 	})
			// }
			// //#endif
		},
		onShow() {
			// this.checkLogin(0);
			if (this.currUser.islogin) {
				this.getList("refresh");
				// console.log(11)
				// 添加完订阅时跳转回来时提示消息
				//#ifdef APP-PLUS
				this.isKaiqiTongzhi();
				if (!this.tuisong) {
					//弹窗每天只弹一次-张家铭20250626
					let date =new Date()
					let  today = uni.$u.timeFormat(date, 'yyyy-mm-dd')
					let  tongzhiShowdate = uni.getStorageSync('tongzhiShowdate') || ''
					
					if(today != tongzhiShowdate ||tongzhiShowdate==null || tongzhiShowdate=='' || new Date(today) > new Date(tongzhiShowdate)){
						this.$nextTick(() => {
							this.$refs['showpowerPop'].open()
						})
						uni.setStorageSync('tongzhiShowdate',today)
					}
					//之前写法
					// this.$nextTick(() => {
					// 	this.$refs['showpowerPop'].open()
					// })
				}
				//#endif

				this.getgcList("refresh");
			} else {
				uni.navigateTo({
					url: '/pages/user/login/login1?fromurl=/pages/user/custom/custom&type=tab'
				})
			};
			// 隐藏原生的tabbar
			uni.hideTabBar();
		},
		mounted() {
			const query = uni.createSelectorQuery().in(this);
			query.select('.headerCont').boundingClientRect(data => {
				this.contHei = data.height
			}).exec();
			var windowHeight = uni.getSystemInfoSync().windowHeight;
			this.swiperHeight = windowHeight - this.contHei
		},
		onPullDownRefresh() {
			//监听下拉刷新动作的执行方法，每次手动下拉刷新都会执行一次
			this.getList("refresh");
			this.getgcList("refresh");
		},
		methods: {
			// 增加置顶功能
			zbZhiding(id) {
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5126;
				data.dyid = id;
				uni.request({
					url: this.baseConfig.serverURL + 'User/custom/ToTopHandler.ashx', //检查更新的服务器地址
					data: data,
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded" //"application/json"
					},
					success: (res) => {
						//console.log(res);
						if (res.statusCode == 200) {
							if (!res.data.ret) {
								uni.showToast({
									title: res.data.msg,
									icon: "none"
								});
							} else {
								//获取成功，绑定
								uni.showToast({
									title: res.data.msg,
									icon: "none"
								});
								this.getList("refresh");
							}
						} else {
							uni.showToast({
								title: '获取失败',
								icon: "none"
							});
						}
					},
					fail: (res) => {
						uni.showToast({
							title: '获取失败，可能已超时！',
							icon: "none"
						});
					}
				})
			},
			gcZhiding(id) {
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5126;
				data.dyid = id;
				uni.request({
					url: this.baseConfig.serverURL + 'User/custom/XmToTopHandler.ashx', //检查更新的服务器地址
					data: data,
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded" //"application/json"
					},
					success: (res) => {
						//console.log(res);
						if (res.statusCode == 200) {
							if (!res.data.ret) {
								uni.showToast({
									title: res.data.msg,
									icon: "none"
								});
							} else {
								//获取成功，绑定
								uni.showToast({
									title: res.data.msg,
									icon: "none"
								});
								this.getgcList("refresh");
							}
						} else {
							uni.showToast({
								title: '获取失败',
								icon: "none"
							});
						}
					},
					fail: (res) => {
						uni.showToast({
							title: '获取失败，可能已超时！',
							icon: "none"
						});
					}
				})
			},
			radioChange: function(evt) {
				for (let i = 0; i < this.items.length; i++) {
					if (this.items[i].value === evt.target.value) {
						this.current = i;
						break;
					}
				}
			},
			togglePopup(type, open) {
				let data = this.initNewData();
				if (open == 'image') {
					uni.navigateTo({
						url: '/pages/user/custom/choose/choose?isaddorupdate=1&type=' + this.current
					});
				} else if (open == 'gc') {
					uni.navigateTo({
						url: '/pages/user/custom/choose/choose?isaddorupdate=1&type=1'
					});
				} else {
					this.type = type
					this.$nextTick(() => {
						this.$refs['show' + open].open()
					})
				}
			},
			cancel(type) {
				this.$refs['show' + type].close()
			},
			yunyingshang() {
				uni.makePhoneCall({
					phoneNumber: this.baseConfig.serverTelHost
				})
			},
			switch1Change: function(e) {
				let currObj = this.listData[e.target.dataset.index];
				if (e.target.value === true) {
					this.dingyueupdate(currObj.id, 2)
					// 此值在状态显示中应该没用，其它地方未确认 add 20241218 by fpli
					currObj.status = 2;
					// 开启时添加推送设置是否开启，如果没有开启则提示开启弹窗
					this.isKaiqiTongzhi();
					if (!this.tuisong) {
						this.$nextTick(() => {
							this.$refs['showpowerPop'].open()
						})
					}
				} else {
					this.dingyueupdate(currObj.id, 1)
					currObj.status = 1;
				}
			},
			gcswitchChange: function(e) {
				let currObj = this.gclistData[e.target.dataset.index];
				console.log(e.target.value);
				if (e.target.value === true) {
					currObj.status = 0;
					this.gcdingyueupdate(currObj.id, 1)

					// 开启时添加推送设置是否开启，如果没有开启则提示开启弹窗
					this.isKaiqiTongzhi();
					if (!this.tuisong) {
						this.$nextTick(() => {
							this.$refs['showpowerPop'].open()
						})
					}

				} else {
					currObj.status = 1;
					this.gcdingyueupdate(currObj.id, 2)
				}
			},
			getList(type) {
				//type add 加载更多 refresh下拉刷新
				// #ifdef APP-PLUS
				if (type === 'refresh') {
					this.refreshing = true;
				}
				// #endif
				//下拉刷新 关闭刷新动画
				if (type === 'refresh') {
					this.$refs.mixPulldownRefresh && this.$refs.mixPulldownRefresh.endPulldownRefresh();
					// #ifdef APP-PLUS
					this.refreshing = false;
					// #endif
				}

				//异步请求数据
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5126;
				//#ifdef APP-PLUS
				if (data.version == null || data.version == '' || data.version == 'null' || data.version == undefined) {
					var t3 = setInterval(function() {
						plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
							if (wgtinfo.version != undefined && wgtinfo.version != '' && wgtinfo.version !=
								'null' && wgtinfo.version !=
								null) {
								data.version = wgtinfo.version;
								clearInterval(t3);
							}
						})
					}, 50);
				}
				//#endif
				// console.log(1,data)
				/**
				 * "system": "ios",
					"cid": "d0686d24d0ba28db9b4c684ef9405681",
					"version": "5.0.5",
				 */
				//data.system='ios'
				// 注：电脑端的浏览器中不显示app中添加的订阅项，原因是：手机端请求参数有cid，后端列表数据和这个有关
				// data.cid= '3322B5D44B3234D891725C35513F49D7'
				// data.version='5.0.5'

				uni.request({
					url: this.baseConfig.serverURL + 'User/custom/ListHandler.ashx', //检查更新的服务器地址
					data: data,
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded" //"application/json"
					},
					success: (res) => {

						if (res.statusCode == 200) {
							if (!res.data.ret) {
								// uni.showToast({
								// 	title: res.data.msg,
								// 	icon: "none"
								// });
							} else {
								uni.stopPullDownRefresh();
								//获取成功，绑定
								if (type == 'refresh') {
									this.listData = []; //刷新前清空数组
									this.maillistData = [];
								}
								let list = res.data.other2.list;
								console.log(list)
								if (list == undefined || list == '' || list.length <= 0) {

								} else {
									list.forEach(item => {
										this.listData.push(item);
									})
									this.listisnone = false;
								}
								let maillist = res.data.other2.maillist;
								console.log(maillist)
								if (maillist == undefined || maillist == '' || maillist.length <= 0) {

								} else {
									maillist.forEach(item => {
										this.maillistData.push(item);
									})
									this.listisnone = false;
								}
								if ((maillist == undefined || maillist == '' || maillist.length <= 0) && (
										list == undefined || list == '' ||
										list.length <= 0)) {
									this.listisnone = true;
									this.refreshing = false;
									return;
								}
							}
						} else {
							uni.showToast({
								title: '获取失败!',
								icon: "none"
							});
							this.listisnone = true;
							uni.stopPullDownRefresh();
							this.refreshing = false;
						}
					},
					fail: (res) => {
						uni.showToast({
							title: '获取失败！',
							icon: "none"
						});
					}
				})
			},
			getgcList(type) {
				//type add 加载更多 refresh下拉刷新
				// #ifdef APP-PLUS
				if (type === 'refresh') {
					this.refreshing = true;
				}
				// #endif
				//下拉刷新 关闭刷新动画
				if (type === 'refresh') {
					this.$refs.mixPulldownRefresh && this.$refs.mixPulldownRefresh.endPulldownRefresh();
					// #ifdef APP-PLUS
					this.refreshing = false;
					// #endif
				}
				//异步请求数据
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5126;
				//#ifdef APP-PLUS
				
				if (data.version == null || data.version == '' || data.version == 'null' || data.version == undefined) {
					var t3 = setInterval(function() {
						plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
							if (wgtinfo.version != undefined && wgtinfo.version != '' && wgtinfo.version !=
								'null' && wgtinfo.version !=
								null) {
								data.version = wgtinfo.version;
								clearInterval(t3);
							}
						})
					}, 50);
				}
				
				//#endif
				uni.request({
					url: this.baseConfig.serverURL + 'User/custom/xmListHandler.ashx', //检查更新的服务器地址
					data: data,
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded" //"application/json"
					},
					success: (res) => {
						//console.log(res);
						if (res.statusCode == 200) {
							if (!res.data.ret) {
								// uni.showToast({
								// 	title: res.data.msg,
								// 	icon: "none"
								// });
							} else {
								uni.stopPullDownRefresh();
								//获取成功，绑定
								if (type === 'refresh') {
									this.gclistData = []; //刷新前清空数组
								}
								let list = res.data.other2.list;
								if (list == undefined || list == '' || list.length <= 0) {
									this.gclistisnone = true;
									this.refreshing = false;
									return;
								} else {
									list.forEach(item => {
										this.gclistData.push(item);
									})
									this.gclistisnone = false;
								}
							}
						} else {
							uni.showToast({
								title: '获取工程订阅信息失败!',
								icon: "none"
							});
							this.gclistisnone = true;
							uni.stopPullDownRefresh();
							this.refreshing = false;
						}
					},
					fail: (res) => {
						uni.showToast({
							title: '获取工程订阅信息失败！',
							icon: "none"
						});
					}
				})
			},

			modify(item) {
				let data = this.initNewData();
				
				
					uni.navigateTo({
						url: '/pages/user/custom/choose/choose?id=' + item.id + '&isaddorupdate=2&type=0'
					});
				

			},
			gcmodify(item) {
				let data = this.initNewData();
				
				
					uni.navigateTo({
						url: '/pages/user/custom/choose/choose?id=' + item.id + '&isaddorupdate=2&type=1'
					});
				

			},
			dingyueupdate(id, state) {
				//异步请求数据
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5126;
				data.id = id;
				data.state = state;
				// 删除确认框
				if (state == 3) {
					const me = this;
					uni.showModal({
						title: '',
						content: '确认删除该订阅？',
						success: function(res) {
							if (res.confirm) {
								uni.request({
									url: me.baseConfig.serverURL +
										'User/custom/UpdateStatus.ashx', //检查更新的服务器地址
									data: data,
									method: "POST",
									header: {
										"content-type": "application/x-www-form-urlencoded" //"application/json"
									},
									success: (res) => {
										if (res.statusCode == 200) {
											if (!res.data.ret) {
												uni.showToast({
													title: res.data.msg,
													icon: "none"
												});
											} else {
												//获取成功，绑定
												uni.showToast({
													title: res.data.msg,
													icon: "none"
												});
												if (state == 3) {
													me.getList("refresh");
												}
											}
										} else {
											uni.showToast({
												title: '获取失败',
												icon: "none"
											});
										}
									},
									fail: (res) => {
										uni.showToast({
											title: '获取失败，可能已超时！',
											icon: "none"
										});
									}
								})
							}
						}
					});
				}

			},
			gcdingyueupdate(id, state) {
				console.log(id);
				//异步请求数据
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5126;
				data.id = id;
				data.state = state;
				if (state == 3) {
					const me = this;
					uni.showModal({
						title: '',
						content: '确认删除该订阅？',
						success: function(res) {
							uni.request({
								url: me.baseConfig.serverURL +
									'User/custom/xmUpdateStatus.ashx', //检查更新的服务器地址
								data: data,
								method: "POST",
								header: {
									"content-type": "application/x-www-form-urlencoded" //"application/json"
								},
								success: (res) => {
									//console.log(res);
									if (res.statusCode == 200) {
										if (!res.data.ret) {
											uni.showToast({
												title: res.data.msg,
												icon: "none"
											});
										} else {
											//获取成功，绑定
											uni.showToast({
												title: res.data.msg,
												icon: "none"
											});
											if (state == 3) {
												me.getgcList("refresh");
											}
										}
									} else {
										uni.showToast({
											title: '获取失败，当前状态码为：' + res.statusCode,
											icon: "none"
										});
									}
								},
								fail: (res) => {
									uni.showToast({
										title: '获取失败，可能已超时！',
										icon: "none"
									});
								}
							})
						}
					});
				}


			},
			goDetail: function(item) {
				uni.navigateTo({
					url: '/pages/user/custom/zblist/zblist?id=' + item.id + '&keyword=' + item.keyword
				});
			},
			goDetailmail: function(item) {
				uni.navigateTo({
					url: '/pages/user/custom/zblist/zblist?id=' + item.id + '&keyword=' + item.keyword +
						'&mail=1'
				});
			},
			gcResultlist: function(item) {
				uni.navigateTo({
					url: '/pages/user/custom/gclist/gclist?id=' + item.id + '&keyword=' + item.typestr
				});
			},
			onClickItem(val) {
				this.current = val.currentIndex;
			},
			mailclick() {
				uni.showToast({
					title: '邮件定制信息只能在PC端操作',
					icon: "none"
				});
			},
			isKaiqiTongzhi() {
				// #ifdef APP-PLUS
				if (uni.getSystemInfoSync().platform == 'ios') {
					var UIApplication = plus.ios.import("UIApplication");
					var app = UIApplication.sharedApplication();
					var enabledTypes = 0;
					if (app.currentUserNotificationSettings) {
						var settings = app.currentUserNotificationSettings();
						enabledTypes = settings.plusGetAttribute("types");
						console.log("enabledTypes1:" + enabledTypes);
						if (enabledTypes == 0) {
							this.tuisong = false;
						} else {
							this.tuisong = true;
						}
					} else {
						enabledTypes = app.enabledRemoteNotificationTypes();
						if (enabledTypes == 0) {
							this.tuisong = false;
						} else {
							this.tuisong = true;
						}
						console.log("enabledTypes2:" + enabledTypes);
					}
					plus.ios.deleteObject(app);

				} else if (uni.getSystemInfoSync().platform == 'android') {
					//安卓
					let main = plus.android.runtimeMainActivity();
					let pkName = main.getPackageName();
					let NotificationManagerCompat = plus.android.importClass(
						"android.support.v4.app.NotificationManagerCompat");

					// android.support.v4升级为androidx
					if (NotificationManagerCompat == null) {
						NotificationManagerCompat = plus.android.importClass(
							"androidx.core.app.NotificationManagerCompat");
					}

					let packageNames = NotificationManagerCompat.from(main);
					if (!packageNames.areNotificationsEnabled()) { //手机没有开启通知的权限
						this.tuisong = false;
					} else {
						this.tuisong = true;
					}
				}
				// #endif 
			},
			Setup() {
				/* 获取当前手机是否有通知权限 */
				// #ifdef APP-PLUS
				if (uni.getSystemInfoSync().platform == 'ios') {
					var app = plus.ios.invoke('UIApplication', 'sharedApplication');
					var setting = plus.ios.invoke('NSURL', 'URLWithString:', 'app-settings:');
					plus.ios.invoke(app, 'openURL:options:completionHandler:', setting);
					plus.ios.deleteObject(setting);
					plus.ios.deleteObject(app); 
					
				} else if (uni.getSystemInfoSync().platform == 'android') {
					//安卓
					let main = plus.android.runtimeMainActivity();
					let pkName = main.getPackageName();
					let NotificationManagerCompat = plus.android.importClass(
						"android.support.v4.app.NotificationManagerCompat");

					// android.support.v4升级为androidx
					if (NotificationManagerCompat == null) {
						NotificationManagerCompat = plus.android.importClass(
							"androidx.core.app.NotificationManagerCompat");
					}

					let uid = main.getApplicationInfo().plusGetAttribute("uid");
					let Intent = plus.android.importClass('android.content.Intent');
					let Build = plus.android.importClass("android.os.Build");
					//android 8.0引导  
					if (Build.VERSION.SDK_INT >= 26) {
						let intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
						intent.putExtra('android.provider.extra.APP_PACKAGE', pkName);
						// 跳转到该应用的系统通知设置页
						main.startActivity(intent);
					} else if (Build.VERSION.SDK_INT >= 21) { //android 5.0-7.0  
						let intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
						intent.putExtra("app_package", pkName);
						intent.putExtra("app_uid", uid);
						// 跳转到该应用的系统通知设置页
						main.startActivity(intent);
					} else { //(<21)其他--跳转到该应用管理的详情页
						let Settings = plus.android.importClass("android.provider.Settings");
						let Uri = plus.android.importClass("android.net.Uri");
						let intent = new Intent();
						intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
						let uri = Uri.fromParts("package", main.getPackageName(), null);
						intent.setData(uri);
						// 跳转到该应用的系统通知设置页
						main.startActivity(intent);
					}
				}
				// #endif 
				/* 获取当前手机是否有通知权限 */
			}
		}
	}
</script>

<style lang="scss">
	@import "@/static/css/custom/custom.scss";

	.gongcheng-custom {
		.custom-list-item {
			width: 100%;

			.list-item-box {
				.custom-keywords {
					background-color: #f98d28;
				}

				.custom-editor {
					.custom-results {
						color: #f98d28;
						border-color: #f98d28;
					}
				}
			}
		}
	}

	.custom-container {
		// position: absolute;
		// width: 100%;
		// height: 100%;
	}

	.fxied {
		margin: 0 !important;
	}

	.youx-switch {
		position: relative;

		.switch-mask {
			background-color: rgba($color: #ffffff, $alpha: 0.5);
			position: absolute;
			top: 10rpx;
			left: 20rpx;
			width: 65%;
			height: 40rpx;
			z-index: 99;
		}
	}

	.powerPop {
		//position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		//background-color: rgba(0, 0, 0, 0.5);
		//z-index: 999;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: flex-end;
		padding: 0 57rpx;
		box-sizing: border-box;

		.power_cont {
			width: 636rpx;
			background-color: #FFFFFF;
			border-radius: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 30rpx 0 40rpx;

			.quanxiantongzhi-img {
				width: 567rpx;
				height: 341rpx;
			}

			.lijikaiqi {
				height: 67rpx;
				line-height: 67rpx;
				background-color: #fc7502;
				border-radius: 67rpx;
				width: 345rpx;
				color: #FFFFFF;
				font-size: 30rpx;
				text-align: center;
				margin-top: 20rpx;
			}
		}

		.power-close {
			width: 56rpx;
			height: 56rpx;
			margin-bottom: 20rpx;
		}
	}
	.custom-nav .u-navbar__content__title{
		font-size: 34rpx;
	}
	.custom-nav ::v-deep .u-navbar__content__right__text{
		color: #366DE1;
		font-size: 30rpx;
	}
</style>